package playlist;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;

public class MainScreenListener extends Form implements CommandListener {

	private final Command nextCommand
		= new Command("Next", Command.ITEM, 1);
	
    private final Command okCommand =
        new Command("OK", Command.OK, 1);

	private Crawler midlet;

	public MainScreenListener(Crawler aMidlet) {
		super ("Crawler");

		addCommand(nextCommand);
		midlet = aMidlet;
		setCommandListener(this);
		
	}

	public void commandAction(Command command, Displayable diplayable) {

		append("Command : " + command.getCommandType() + '\n');
		
		if (command == nextCommand) {
			
//			append("Button 'Next' was pushed.");
			
			try {
				midlet.playNextMP3();
			} catch (Throwable e) {
				e.printStackTrace();
				this.append("Error\n" + e.getMessage());
			}
		}
	}

}
